package cn.net.yto.school.dao.repositories;

import cn.net.yto.base.dao.BaseRepository;
import cn.net.yto.school.dao.dto.ClazzStudentCountStsDto;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import cn.net.yto.school.dao.entities.TbClazz;

import java.util.List;

/**
 * tb_clazz Repository
 * Created by gaojing
 * Wed Jul 18 19:29:33 CST 2018
 */
@Repository
public interface TbClazzRepository extends BaseRepository<TbClazz, Integer> {

    @Query(value = "SELECT tc.cls_id, tc.cls_name, COUNT(tc.cls_id) count_num FROM tb_clazz tc \n" +
            "\tRIGHT JOIN tb_student ts \n" +
            "\tON tc.cls_id = ts.cls_id\n" +
            "\tGROUP BY ts.cls_id;", nativeQuery = true)
    List<ClazzStudentCountStsDto> countClazzStudent();
}

